export function tansParams(params) {
	let result = '';
	if (!Object.keys(params).length) {
		return result;
	}
	for (const propName of Object.keys(params)) {
		const value = params[propName];
		var part = encodeURIComponent(propName) + "=";
		if (value !== null && value !== "" && typeof (value) !== "undefined") {
			if (typeof value === 'object') {
				if (typeof value.length == 'number' || Object.keys(value).length) {
					// 数组或者对象
					result += part + value + "&";
				} else {
					// 对象
					for (const key of Object.keys(value)) {
						if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') {
							let params = propName + '[' + key + ']';
							var subPart = encodeURIComponent(params) + "=";
							result += subPart + encodeURIComponent(value[key]) + "&";
						}
					}
				}
			} else {
				result += part + encodeURIComponent(value) + "&";
			}
		}
	}

	return result
}
// 获取ack
export function getAck(a) {
	let b = new Date()['getTime']() + '',
		c = a ? b['substr'](-0x3) + a['substr'](-0x1) : b['substr'](-0x4),
		d = (c * 0x21 - 0xb) * 0x16;
	return c + '' + d;
}
// 时间戳转换天-小时-分-秒
export function convertSeconds(time) {
	let seconds = Number(time) / 1000;
	const days = Math.floor(seconds / (24 * 3600));
	const hours = Math.floor((seconds % (24 * 3600)) / 3600);
	const minutes = Math.floor((seconds % 3600) / 60);
	const secs = Math.floor(seconds % 60);
	let str = "";
	if (days) {
		str += `${days}天`;
	}
	if (hours) {
		str += `${hours}小时`;
	}
	if (minutes) {
		str += `${minutes}分`;
	}
	str += `${secs}秒`;
	return str;
}

// 小时转换天-小时
export function convertHours(time) {
	const days = Math.floor(time / 24);
	const hour = Math.floor(time % 24);
	let str = "";
	if (days) {
		str += `${days}天`;
	}
	str += `${hour}小时`;
	return str;
}